﻿/**
* 命名空间: ICS_ViewModel
*
* 功 能： N/A
* 类 名： DeviceInfo
*
* Ver 变更日期 负责人 变更内容
* ───────────────────────────────────
* V0.01 2021/9/16 8:28:08 小柚子爱学习 初版
*
* Copyright (c) 2021 Lir Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为个人机密信息，未经本人书面同意禁止向第三方披露．　│
*│　版权所有：Vip_Future 　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using ICS_Equipment;
using ICS_Equipment.CoolingPump;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Input;

namespace ICS_ViewModel
{
    
    public class DeviceInfo : INotifyPropertyChanged
    {
        #region 组件定位 及大小调整
        public int DeviceType { get; set; }
        private string _senderObj;
        /// <summary>
        /// 
        /// </summary>
        public string SenderObj
        {
            get { return _senderObj; }
            set
            {
                _senderObj = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SenderObj"));
            }
        }
        private double _left;
        public double Left { get { return _left; }set {
                _left = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Left"));
            } }

        private double _top;
        public double Top
        {
            get { return _top; }
            set
            {
                _top = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Top"));
            }
        }
        private double _width=100;
        public double Width
        {
            get { return _width; }
            set
            {
                _width = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Width"));
            }
        }
        private double _height=50;
        public double Height
        {
            get { return _height; }
            set
            {
                _height = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Height"));
            }
        }
        public FrameworkElement Container { get; set; }
        #endregion
        bool _isMove = false;
        FrameworkElement _moveObj = null;
        Point _downPoint = new Point();
        MouseButtonEventArgs eventObj;
        public void LeftButtonDown(object sender, MouseButtonEventArgs e){
            _moveObj = sender as BlueCoolingPump;

            eventObj = e;
            _downPoint = e.GetPosition(_moveObj);
            _isMove = true;
        }
        public void LeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            _isMove = false;
            _moveObj = null;
        }
        public void DoMove(object sender, MouseEventArgs e)
        {
            if (_isMove)
            {
                //需要通过容器对象拿到对应坐标
                Point point = e.GetPosition(Container);
              this.Left= point.X - _downPoint.X;
               this.Top=point.Y - _downPoint.Y;
            }
        }
        private CommandBase _mouseMove;
        public CommandBase MouseMoveCommand
        {
            get{
                if (_mouseMove == null)
                {
                    _mouseMove = new CommandBase();
                    _mouseMove.DoExecute = new Action<object>(obj => {
                        if (_isMove)
                        {
                            //需要通过容器对象拿到对应坐标
                            Point point = eventObj.GetPosition((IInputElement)obj);
                            this.Left = point.X - _downPoint.X;
                            this.Top = point.Y - _downPoint.Y;
                        }
                    });
                }
                return _mouseMove;
            }
            
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
